/****************************************************
	文件：LoadingView.cs
	作者：HuskyT
	邮箱：1005240602@qq.com
	日期：2021/1/17 18:8:36
	功能：加载界面
*****************************************************/

using HTFW.Scene;
using HTFW.Utility;
using UnityEngine.UI;

namespace HTFW.UI
{
    [BindPrefab(UIPreafbPath.UI_LOADING)]
    public class LoadingView : ViewBase
    {
        Text mTxt_Progress;
        Slider mSli_Progress;

        public override void SetupUI()
        {
            mUILayer = UILayer.HUD;
            mUIType = UIType.Once;
        }

        protected override void OnInit()
        {
            mTxt_Progress = Transform.Find("Sli_Progress/Txt_Progress").GetComponent<Text>();
            mSli_Progress = Transform.Find("Sli_Progress").GetComponent<Slider>();
        }

        protected override void Update()
        {
            if (SceneManager.Instance.IsAlreadyLoaded) return;
        }

        public void SetProgress(int progress)
        {
            mTxt_Progress.text = $"{progress}%";
            mSli_Progress.value = 1.0f * progress / 100.0f;
        }
    }
}